home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / f90 / index.z / index
Encoding:
Text File  |  2002-10-03  |  3.9 KB  |  95 lines

  1. INDEX(3I)                                             Last changed: 4-13-99
  2.  
  3.  
  4. NNAAMMEE
  5.      IINNDDEEXX - Determines the starting location of a character substring in a
  6.      string
  7.  
  8. SSYYNNOOPPSSIISS
  9.      IINNDDEEXX (([SSTTRRIINNGG==]_s_t_r_i_n_g,, [SSUUBBSSTTRRIINNGG==]_s_u_b_s_t_r_i_n_g [,,[BBAACCKK==]_b_a_c_k]))
  10.  
  11. IIMMPPLLEEMMEENNTTAATTIIOONN
  12.      UNICOS, UNICOS/mk, IRIX systems
  13.  
  14.      CF90, MIPSpro 7 Fortran 90, MIPSpro Fortran 77
  15.  
  16. SSTTAANNDDAARRDDSS
  17.      Fortran
  18.  
  19. DDEESSCCRRIIPPTTIIOONN
  20.      The IINNDDEEXX intrinsic function returns the starting position of a
  21.      substring within a string from either the right or left end of the
  22.      string.  It accepts the following arguments:
  23.  
  24.      _s_t_r_i_n_g    Must be of type character.
  25.  
  26.      _s_u_b_s_t_r_i_n_g Must be of type character.
  27.  
  28.      _b_a_c_k      Must be of type logical.  If omitted, a value of false is
  29.                assumed.  If present with a value of true, the search begins
  30.                at the end of _s_t_r_i_n_g.  This argument is not accepted by the
  31.                MIPSpro Fortran 77 compiler.
  32.  
  33.      IINNDDEEXX is an elemental function.  The name of this intrinsic can be
  34.      passed as an argument.
  35.  
  36. NNOOTTEESS
  37.      When the IINNDDEEXX intrinsic function is passed as an actual argument, it
  38.      must be called with only the first two arguments in the routine that
  39.      calls the passed-in function.
  40.  
  41. RREETTUURRNN VVAALLUUEESS
  42.      The _b_a_c_k argument can affect the return value as follows:
  43.  
  44.      * If _b_a_c_k is absent or is present with the value FFAALLSSEE, the IINNDDEEXX
  45.        search is relative to the left end of _s_t_r_i_n_g.  The result is the
  46.        minimum positive value of _i, as follows:
  47.  
  48.           _s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
  49.  
  50.        If the length of _s_u_b_s_t_r_i_n_g is 0, a value of 1 is returned.
  51.  
  52.      * If _b_a_c_k is present with the value TTRRUUEE, the IINNDDEEXX search is relative
  53.        to the right end of _s_t_r_i_n_g.  The result is the maximum positive
  54.        value of the following:
  55.  
  56.           _i <<== LLEENN(( _s_t_r_i_n_g )) -- LLEENN(( _s_u_b_s_t_r_i_n_g )) ++ 11
  57.  
  58.        In the preceding equation, _s_u_b_s_t_r_i_n_g is as follows:
  59.  
  60.           _s_t_r_i_n_g (( _i :: _i ++ LLEENN(( _s_u_b_s_t_r_i_n_g )) -- 11 )) == _s_u_b_s_t_r_i_n_g
  61.  
  62.        If the length of _s_u_b_s_t_r_i_n_g is 0, the value returned is as follows:
  63.  
  64.           LLEENN(( _s_t_r_i_n_g )) ++ 11.
  65.  
  66.      If _s_u_b_s_t_r_i_n_g occurs more than once in _s_t_r_i_n_g, IINNDDEEXX returns the index
  67.      to the first occurrence.
  68.  
  69.      The return value is 0 if _s_u_b_s_t_r_i_n_g is not located within _s_t_r_i_n_g.
  70.  
  71.      The return value is 0 if the length of _s_t_r_i_n_g is less than the length
  72.      of _s_u_b_s_t_r_i_n_g.
  73.  
  74. EEXXAAMMPPLLEESS
  75.      Example 1:  IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'')) has the value 3.
  76.  
  77.      Example 2:  IINNDDEEXX((''FFOORRTTRRAANN'',,''RR'',,BBAACCKK==..TTRRUUEE..)) has the value 5.
  78.  
  79.      Example 3:  The following program returns the index II==1100 for the
  80.      substring SSUUPPEERRCCOOMMPPUUTTEERR:
  81.  
  82.           PROGRAM INDEX1
  83.           CHARACTER*22 A
  84.           CHARACTER*13 B
  85.           A = 'CRAY T90 SUPERCOMPUTER'
  86.           B = 'SUPERCOMPUTER'
  87.           I = INDEX(A,B)
  88.           PRINT *, I
  89.           STOP
  90.           END
  91.  
  92. SSEEEE AALLSSOO
  93.      _I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l for the printed version of this
  94.      man page.
  95.